# Seymore - Content Management on Rails
# 
# Copyright (c) 2006 - 2007 Thomas Mango
# 
# For license information, please visit:
# http://code.google.com/p/seymore/
# 
# File created by Thomas Mango [tsmango@gmail.com]

class LoginController < ApplicationController
  layout "page"
  
  def index
    if request.get?
      session[:user] = nil
      @user = User.new
    else
      @user = User.new(params[:user])
      logged_in_user = @user.try_to_login
      if logged_in_user != nil
        session[:user] = logged_in_user
        redirect_to (:controller => "page")
      else
        flash[:notice] = "Invalid user/password combination"
      end
    end
  end
end
